package view.test;

import java.awt.Point;
import java.awt.event.MouseEvent;

import javax.swing.event.MouseInputListener;

import model.GameModel;
import model.ModelLockedException;
import model.entities.IEntity;

public class EntityMouseInputListener implements MouseInputListener {
	
	private GameModel model; // ,make this the controller later!!1 TODO
	private Point cell;
	
	public EntityMouseInputListener(GameModel model, Point cell) {
		this.model = model;
		this.cell = cell;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		
		IEntity entity = model.getGameBoard().getEntityAtCell(cell); // again, controller TODO
		if (entity == null)
			return;
		
		entity.handleClick(e.getButton());
		
		// let the controller do this later! TODO
		try {
			model.setDirty();
		} catch (ModelLockedException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

	}

	@Override
	public void mouseEntered(MouseEvent arg0) {}
	@Override
	public void mouseExited(MouseEvent arg0) {}
	@Override
	public void mousePressed(MouseEvent arg0) {}
	@Override
	public void mouseReleased(MouseEvent arg0) {}
	@Override
	public void mouseDragged(MouseEvent arg0) {}
	@Override
	public void mouseMoved(MouseEvent arg0) {}

}
